import {Component, ViewChild} from "@angular/core";
import {Nav, Platform} from "ionic-angular";
import {StatusBar} from "@ionic-native/status-bar";
import {SplashScreen} from "@ionic-native/splash-screen";
import {HomePage} from "../pages/home/home";
import {ActivityPage} from "../pages/activity/activity";
import {UserPage} from "../pages/user/user";
import {AboutPage} from "../pages/about/about";
import {ActivityAddPage} from "../pages/activity/add/add";
import {LoginPage} from "../pages/login/login";
import {ListPage} from "../pages/list/list";
import {MapNavigationPage} from "../pages/map/navigation/navigation";
import {SitePage} from "../pages/activity/site/site";
import { Geolocation } from '@ionic-native/geolocation';

@Component({
  templateUrl: 'app.html'
})
export class MyApp {
  @ViewChild(Nav) nav: Nav;

  rootPage: any = SitePage;

  pages: Array<{title: string, component: any}>;

  constructor(public platform: Platform, public statusBar: StatusBar, public splashScreen: SplashScreen,public  geolocation: Geolocation) {
    this.initializeApp();

    // used for an example of ngFor and navigation
    this.pages = [
      {title: 'Activity', component: ActivityPage},
      {title: 'User', component: UserPage},
      {title: 'About', component: AboutPage}
    ];

  }

  initializeApp() {
    this.platform.ready().then(() => {
      // Okay, so the platform is ready and our plugins are available.
      // Here you can do any higher level native things you might need.
      this.statusBar.styleDefault();
      this.splashScreen.hide();

      // this.geolocation.getCurrentPosition().then((resp) => {
      //   // resp.coords.latitude
      //   // resp.coords.longitude
      //   console.log(resp.coords.latitude + ">>>" + resp.coords.longitude);
      // }).catch((error) => {
      //   console.log('Error getting location', error);
      // });

    });

  }

  openPage(page) {
    // Reset the content nav to have just this page
    // we wouldn't want the back button to show in this scenario
    this.nav.setRoot(page.component);
  }
}
